//    Copyright (C) 2013  <lugocreation@gmail.com>
//
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.
package org.jpgolay.me.sending;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import org.jpgolay.gui.date.DateComboBox;
import org.jpgolay.me.util.MEDate;
import org.jpgolay.me.util.MEUtility;

// Referenced classes of package org.jpgolay.me.sending:
//            Messages
public class SendingPanel extends JPanel {

    public SendingPanel() {
        jPanel = null;
        lastUpdateUserLabel = null;
        lastUpdateTimeLabel = null;
        idLabel = null;
        agencyIdLabel = null;
        agencyIdTextField = null;
        preparationDateLabel = null;
        preparationDateTextField = null;
        deliveryFormLabel = null;
        deliveryFormTextField = null;
        truckingCompanyLabel = null;
        truckingCompanyTextField = null;
        customerGLNLabel = null;
        customerGLNTextField = null;
        customerIDLabel = null;
        customerIDTextField = null;
        palletGTINLabel = null;
        palletGTINTextField = null;
        boxGTINLabel = null;
        boxGTINTextField = null;
        orderIdLabel = null;
        orderIdTextField = null;
        statusLabel = null;
        statusTextField = null;
        sSCCLabel = null;
        sSCCTextField = null;
        insuranceCompanyLabel = null;
        insuranceCompanyTextField = null;
        parcelQuantityLabel = null;
        parcelQuantityTextField = null;
        sendingDateLabel = null;
        sendingDateTextField = null;
        deliveryAnticipatedDateLabel = null;
        deliveryAnticipatedDateTextField = null;
        packagingLabel = null;
        packagingTextField = null;
        unitLabel = null;
        unitTextField = null;
        notesLabel = null;
        notesTextField = null;
        weightLabel = null;
        weightTextField = null;
        deliveryDateLabel = null;
        deliveryDateTextField = null;
        insuranceValueLabel = null;
        insuranceValueTextField = null;
        agencyId = 0;
        preparationDate = null;
        deliveryForm = null;
        truckingCompany = null;
        customerGLN = null;
        customerID = null;
        palletGTIN = null;
        boxGTIN = null;
        orderId = null;
        status = 0;
        sSCC = null;
        insuranceCompany = null;
        parcelQuantity = null;
        sendingDate = null;
        deliveryAnticipatedDate = null;
        packaging = null;
        unit = null;
        notes = null;
        weight = null;
        deliveryDate = null;
        insuranceValue = null;
        lastUpdateUser = null;
        lastUpdateTime = null;
        id = null;
        jPanel1 = null;
        jPanel2 = null;
        jPanel3 = null;
        jPanel4 = null;
        jPanel5 = null;
        initialize();
    }

    private void initialize() {
        setLayout(new FlowLayout());
        setSize(340, 320);
        setPreferredSize(new Dimension(340, 320));
        add(getJPanel(), null);
    }

    private JPanel getJPanel() {
        if (jPanel == null) {
            JLabel lastUpdateUserLabel = new JLabel();
            JLabel lastUpdateTimeLabel = new JLabel();
            JLabel idLabel = new JLabel();
            jPanel = new JPanel();
            jPanel.setLayout(null);
            jPanel.setPreferredSize(new Dimension(330, 310));
            jPanel.setBackground(new Color(0, 0, 153));
            jPanel.add(getJPanel1(), null);
            jPanel.add(getJPanel2(), null);
            jPanel.add(getJPanel3(), null);
            jPanel.add(getJPanel5(), null);
            jPanel.add(getJPanel4(), null);
        }
        return jPanel;
    }

    private JPanel getJPanel1() {
        if (jPanel1 == null) {
            jPanel1 = new JPanel();
            FlowLayout flowLayout1 = new FlowLayout();
            jPanel1.setLayout(flowLayout1);
            jPanel1.setPreferredSize(new Dimension(1, 1));
            jPanel1.setBackground(new Color(120, 255, 120));
            jPanel1.setSize(326, 26);
            jPanel1.setLocation(2, 2);
            flowLayout1.setHgap(2);
            flowLayout1.setVgap(2);
            jPanel1.add(getAgencyIdLabel(), null);
            jPanel1.add(getAgencyIdTextField(), null);
            jPanel1.add(getPreparationDateLabel(), null);
            jPanel1.add(getPreparationDateTextField(), null);
        }
        return jPanel1;
    }

    private JPanel getJPanel2() {
        if (jPanel2 == null) {
            jPanel2 = new JPanel();
            FlowLayout flowLayout2 = new FlowLayout();
            jPanel2.setLayout(flowLayout2);
            jPanel2.setBackground(new Color(140, 255, 140));
            jPanel2.setSize(326, 50);
            jPanel2.setLocation(2, 30);
            flowLayout2.setHgap(2);
            flowLayout2.setVgap(2);
            jPanel2.add(getDeliveryFormLabel(), null);
            jPanel2.add(getDeliveryFormTextField(), null);
            jPanel2.add(getTruckingCompanyLabel(), null);
            jPanel2.add(getTruckingCompanyTextField(), null);
            jPanel2.add(getCustomerGLNLabel(), null);
            jPanel2.add(getCustomerGLNTextField(), null);
            jPanel2.add(getCustomerIDLabel(), null);
            jPanel2.add(getCustomerIDTextField(), null);
        }
        return jPanel2;
    }

    private JPanel getJPanel3() {
        if (jPanel3 == null) {
            jPanel3 = new JPanel();
            FlowLayout flowLayout3 = new FlowLayout();
            jPanel3.setLayout(flowLayout3);
            jPanel3.setBackground(new Color(160, 255, 160));
            jPanel3.setSize(326, 26);
            jPanel3.setLocation(2, 82);
            flowLayout3.setHgap(2);
            flowLayout3.setVgap(2);
            jPanel3.add(getSSCCLabel(), null);
            jPanel3.add(getSSCCTextField(), null);
            jPanel3.add(getPalletGTINLabel(), null);
            jPanel3.add(getPalletGTINTextField(), null);
        }
        return jPanel3;
    }

    private JPanel getJPanel4() {
        if (jPanel4 == null) {
            jPanel4 = new JPanel();
            FlowLayout flowLayout4 = new FlowLayout();
            jPanel4.setLayout(flowLayout4);
            jPanel4.setBackground(new Color(200, 255, 200));
            jPanel4.setSize(326, 26);
            jPanel4.setLocation(2, 282);
            flowLayout4.setHgap(2);
            flowLayout4.setVgap(2);
            jPanel4.add(getDeliveryDateLabel(), null);
            jPanel4.add(getDeliveryDateTextField(), null);
            jPanel4.add(getIdLabel(), null);
            jPanel4.add(getLastUpdateTimeLabel(), null);
            jPanel4.add(getLastUpdateUserLabel(), null);
        }
        return jPanel4;
    }

    private JPanel getJPanel5() {
        if (jPanel5 == null) {
            jPanel5 = new JPanel();
            FlowLayout flowLayout5 = new FlowLayout();
            jPanel5.setLayout(flowLayout5);
            jPanel5.setBackground(new Color(180, 255, 180));
            jPanel5.setSize(326, 170);
            jPanel5.setLocation(2, 110);
            jPanel5.setPreferredSize(new Dimension(326, 170));
            flowLayout5.setHgap(2);
            flowLayout5.setVgap(2);
            jPanel5.add(getOrderIdLabel(), null);
            jPanel5.add(getOrderIdTextField(), null);
            jPanel5.add(getStatusLabel(), null);
            jPanel5.add(getStatusTextField(), null);
            jPanel5.add(getInsuranceCompanyLabel(), null);
            jPanel5.add(getInsuranceCompanyTextField(), null);
            jPanel5.add(getInsuranceValueLabel(), null);
            jPanel5.add(getInsuranceValueTextField(), null);
            jPanel5.add(getParcelQuantityLabel(), null);
            jPanel5.add(getParcelQuantityTextField(), null);
            jPanel5.add(getBoxGTINLabel(), null);
            jPanel5.add(getBoxGTINTextField(), null);
            jPanel5.add(getWeightLabel(), null);
            jPanel5.add(getWeightTextField(), null);
            jPanel5.add(getPackagingLabel(), null);
            jPanel5.add(getPackagingTextField(), null);
            jPanel5.add(getUnitLabel(), null);
            jPanel5.add(getUnitTextField(), null);
            jPanel5.add(getSendingDateLabel(), null);
            jPanel5.add(getSendingDateTextField(), null);
            jPanel5.add(getDeliveryAnticipatedDateLabel(), null);
            jPanel5.add(getDeliveryAnticipatedDateTextField(), null);
            jPanel5.add(getNotesLabel(), null);
            jPanel5.add(getNotesTextField(), null);
        }
        return jPanel5;
    }

    private JLabel getIdLabel() {
        if (idLabel == null) {
            idLabel = new JLabel();
            idLabel.setText(Messages.getString("SendingPanel.id"));
            idLabel.setPreferredSize(new Dimension(40, 22));
            idLabel.setHorizontalAlignment(0);
            String s = "<html>Identifiant unique<br>de l'exp\351dition (JGestCom).</html>";
            idLabel.setToolTipText(s);
            idLabel.setFont(new Font("Dialog", 0, 10));
        }
        return idLabel;
    }

    private JLabel getLastUpdateTimeLabel() {
        if (lastUpdateTimeLabel == null) {
            lastUpdateTimeLabel = new JLabel();
            lastUpdateTimeLabel.setText(Messages.getString("SendingPanel.time"));
            lastUpdateTimeLabel.setPreferredSize(new Dimension(68, 22));
            lastUpdateTimeLabel.setHorizontalAlignment(0);
            String s = "<html>Date de la derni\350re<br>modification de l'exp\351dition.</html>";
            lastUpdateTimeLabel.setToolTipText(s);
            lastUpdateTimeLabel.setFont(new Font("Dialog", 0, 10));
        }
        return lastUpdateTimeLabel;
    }

    private JLabel getLastUpdateUserLabel() {
        if (lastUpdateUserLabel == null) {
            lastUpdateUserLabel = new JLabel();
            lastUpdateUserLabel.setText(Messages.getString("SendingPanel.user"));
            lastUpdateUserLabel.setPreferredSize(new Dimension(50, 22));
            lastUpdateUserLabel.setHorizontalAlignment(4);
            String s = "<html>Dernier utilisateur<br>ayant modifi\351 l'exp\351dition.</html>";
            lastUpdateUserLabel.setToolTipText(s);
            lastUpdateUserLabel.setFont(new Font("Dialog", 0, 10));
        }
        return lastUpdateUserLabel;
    }

    private JLabel getAgencyIdLabel() {
        if (agencyIdLabel == null) {
            agencyIdLabel = new JLabel();
            agencyIdLabel.setText(Messages.getString("SendingPanel.agency"));
            agencyIdLabel.setPreferredSize(new Dimension(60, 22));
            agencyIdLabel.setToolTipText("Agence exp\351diant le produit.");
        }
        return agencyIdLabel;
    }

    private JLabel getPreparationDateLabel() {
        if (preparationDateLabel == null) {
            preparationDateLabel = new JLabel();
            preparationDateLabel.setText(Messages.getString("SendingPanel.preparationDate"));
            preparationDateLabel.setPreferredSize(new Dimension(60, 22));
            String s = "<html>Date de pr\351paration<br>de l'exp\351dition.</html>";
            preparationDateLabel.setToolTipText(s);
        }
        return preparationDateLabel;
    }

    private JLabel getDeliveryFormLabel() {
        if (deliveryFormLabel == null) {
            deliveryFormLabel = new JLabel();
            deliveryFormLabel.setText(Messages.getString("SendingPanel.deliveryForm"));
            deliveryFormLabel.setPreferredSize(new Dimension(60, 22));
            String s = "<html>Num\351ro du DESADV<br>ou de l'exp\351dition.<br>Double click pour<br>g\351n\351rer un num\351ro<br>d'exp\351dition interne.</html>";
            deliveryFormLabel.setToolTipText(s);
        }
        return deliveryFormLabel;
    }

    private JLabel getTruckingCompanyLabel() {
        if (truckingCompanyLabel == null) {
            truckingCompanyLabel = new JLabel();
            truckingCompanyLabel.setText(Messages.getString("SendingPanel.truckingCompany"));
            truckingCompanyLabel.setPreferredSize(new Dimension(60, 22));
            String s = "<html>Nom de la compagnie<br>de transports.</html>";
            truckingCompanyLabel.setToolTipText(s);
        }
        return truckingCompanyLabel;
    }

    private JLabel getCustomerGLNLabel() {
        if (customerGLNLabel == null) {
            customerGLNLabel = new JLabel();
            customerGLNLabel.setText(Messages.getString("SendingPanel.customerGLN"));
            customerGLNLabel.setPreferredSize(new Dimension(60, 22));
            String s = "<html>Num\351ro GLN<br>du client.</html>";
            customerGLNLabel.setToolTipText(s);
        }
        return customerGLNLabel;
    }

    private JLabel getCustomerIDLabel() {
        if (customerIDLabel == null) {
            customerIDLabel = new JLabel();
            customerIDLabel.setText(Messages.getString("SendingPanel.customerID"));
            customerIDLabel.setPreferredSize(new Dimension(60, 22));
            String s = "<html>Code du client<br>(JGestCom).</html>";
            customerIDLabel.setToolTipText(s);
        }
        return customerIDLabel;
    }

    private JLabel getPalletGTINLabel() {
        if (palletGTINLabel == null) {
            palletGTINLabel = new JLabel();
            palletGTINLabel.setText(Messages.getString("SendingPanel.palletGTIN"));
            palletGTINLabel.setPreferredSize(new Dimension(60, 22));
            String s = "<html>Num\351ro GTIN<br>de la palette.</html>";
            palletGTINLabel.setToolTipText(s);
        }
        return palletGTINLabel;
    }

    private JLabel getBoxGTINLabel() {
        if (boxGTINLabel == null) {
            boxGTINLabel = new JLabel();
            boxGTINLabel.setText(Messages.getString("SendingPanel.boxGTIN"));
            boxGTINLabel.setPreferredSize(new Dimension(60, 22));
            String s = "<html>Num\351ro GTIN<br>du carton.</html>";
            boxGTINLabel.setToolTipText(s);
        }
        return boxGTINLabel;
    }

    private JLabel getOrderIdLabel() {
        if (orderIdLabel == null) {
            orderIdLabel = new JLabel();
            orderIdLabel.setText(Messages.getString("SendingPanel.orderId"));
            orderIdLabel.setPreferredSize(new Dimension(60, 22));
            String s = "<html>Num\351ro du BL<br>(JGestCom).</html>";
            orderIdLabel.setToolTipText(s);
            orderIdLabel.setForeground(new Color(0, 0, 153));
        }
        return orderIdLabel;
    }

    private JLabel getStatusLabel() {
        if (statusLabel == null) {
            statusLabel = new JLabel();
            statusLabel.setText(Messages.getString("SendingPanel.status"));
            statusLabel.setPreferredSize(new Dimension(60, 22));
            String s = "<html><b>V\351rifi\351 \351gale :</b><br>Contr\364le quantitatif et<br>contr\364le qualitatif<br>des produits exp\351di\351.</html>";
            statusLabel.setToolTipText(s);
        }
        return statusLabel;
    }

    private JLabel getSSCCLabel() {
        if (sSCCLabel == null) {
            sSCCLabel = new JLabel();
            sSCCLabel.setText(Messages.getString("SendingPanel.sSCC"));
            sSCCLabel.setPreferredSize(new Dimension(60, 22));
            String s = "<html>Num\351ro s\351quentiel<br>du colis.</html>";
            sSCCLabel.setToolTipText(s);
        }
        return sSCCLabel;
    }

    private JLabel getInsuranceCompanyLabel() {
        if (insuranceCompanyLabel == null) {
            insuranceCompanyLabel = new JLabel();
            insuranceCompanyLabel.setText(Messages.getString("SendingPanel.insuranceCompany"));
            insuranceCompanyLabel.setPreferredSize(new Dimension(60, 22));
            String s = "<html>Nom de la compagnie<br>d'assurance</html>";
            insuranceCompanyLabel.setToolTipText(s);
        }
        return insuranceCompanyLabel;
    }

    private JLabel getParcelQuantityLabel() {
        if (parcelQuantityLabel == null) {
            parcelQuantityLabel = new JLabel();
            parcelQuantityLabel.setText(Messages.getString("SendingPanel.parcelQuantity"));
            parcelQuantityLabel.setPreferredSize(new Dimension(60, 22));
            parcelQuantityLabel.setHorizontalAlignment(10);
            String s = "<html>Nombre de colis<br>ou de palettes</html>";
            parcelQuantityLabel.setToolTipText(s);
        }
        return parcelQuantityLabel;
    }

    private JLabel getSendingDateLabel() {
        if (sendingDateLabel == null) {
            sendingDateLabel = new JLabel();
            sendingDateLabel.setText(Messages.getString("SendingPanel.sendingDate"));
            sendingDateLabel.setPreferredSize(new Dimension(60, 22));
            sendingDateLabel.setToolTipText("Date d'exp\351dition");
        }
        return sendingDateLabel;
    }

    private JLabel getDeliveryAnticipatedDateLabel() {
        if (deliveryAnticipatedDateLabel == null) {
            deliveryAnticipatedDateLabel = new JLabel();
            deliveryAnticipatedDateLabel.setText(Messages.getString("SendingPanel.deliveryAnticipatedDate"));
            deliveryAnticipatedDateLabel.setPreferredSize(new Dimension(60, 22));
            String s = "<html>Livraison<br>pr\351vue le :</html>";
            deliveryAnticipatedDateLabel.setToolTipText(s);
        }
        return deliveryAnticipatedDateLabel;
    }

    private JLabel getPackagingLabel() {
        if (packagingLabel == null) {
            packagingLabel = new JLabel();
            packagingLabel.setText(Messages.getString("SendingPanel.packaging"));
            packagingLabel.setPreferredSize(new Dimension(60, 22));
            packagingLabel.setToolTipText("Conditionnement");
        }
        return packagingLabel;
    }

    private JLabel getUnitLabel() {
        if (unitLabel == null) {
            unitLabel = new JLabel();
            unitLabel.setText(Messages.getString("SendingPanel.unit"));
            unitLabel.setPreferredSize(new Dimension(60, 22));
            unitLabel.setToolTipText("Unit\351 de conditionnement");
        }
        return unitLabel;
    }

    private JLabel getNotesLabel() {
        if (notesLabel == null) {
            notesLabel = new JLabel();
            notesLabel.setText(Messages.getString("SendingPanel.notes"));
            notesLabel.setPreferredSize(new Dimension(60, 22));
            String s = "<html>Informations<br>sur le produit exp\351di\351 et<br>ces conditions d'emballage</html>";
            notesLabel.setToolTipText(s);
        }
        return notesLabel;
    }

    private JLabel getWeightLabel() {
        if (weightLabel == null) {
            weightLabel = new JLabel();
            weightLabel.setText(Messages.getString("SendingPanel.weight"));
            weightLabel.setPreferredSize(new Dimension(222, 22));
            String s = "<html>Poids du ou<br>des colis en kilo.<br><font color=red><b>Champs obligatoire !</b></font></html>";
            weightLabel.setToolTipText(s);
            weightLabel.setForeground(new Color(0, 0, 153));
        }
        return weightLabel;
    }

    private JLabel getDeliveryDateLabel() {
        if (deliveryDateLabel == null) {
            deliveryDateLabel = new JLabel();
            deliveryDateLabel.setText(Messages.getString("SendingPanel.deliveryDate"));
            deliveryDateLabel.setPreferredSize(new Dimension(60, 22));
            String s = "<html>Date r\351el de<br>la livraison.</html>";
            deliveryDateLabel.setToolTipText(s);
        }
        return deliveryDateLabel;
    }

    private JLabel getInsuranceValueLabel() {
        if (insuranceValueLabel == null) {
            insuranceValueLabel = new JLabel();
            insuranceValueLabel.setText(Messages.getString("SendingPanel.insuranceValue"));
            insuranceValueLabel.setPreferredSize(new Dimension(60, 22));
            insuranceValueLabel.setToolTipText("Valeur assur\351e");
        }
        return insuranceValueLabel;
    }

    private JComboBox getAgencyIdTextField() {
        if (agencyIdTextField == null) {
            agencyIdTextField = new JComboBox();
            agencyIdTextField.setPreferredSize(new Dimension(98, 22));
            agencyIdTextField.setToolTipText("Agence exp\351diant le produit");
            agencyIdTextField.setModel(new DefaultComboBoxModel(new String[]{
                        "Agence 1", "Agence 2", "Agence 3", "Agence 4", "Agence 5"
                    }));
            agencyIdTextField.addItemListener(new ItemListener() {
                public void itemStateChanged(ItemEvent e) {
                    setAgencyId(agencyIdTextField.getSelectedIndex() + 1);
                }
            });
        }
        return agencyIdTextField;
    }

    private DateComboBox getPreparationDateTextField() {
        if (preparationDateTextField == null) {
            preparationDateTextField = new DateComboBox();
            preparationDateTextField.setPreferredSize(new Dimension(98, 22));
            String s = "<html>Date de pr\351paration<br>de l'exp\351dition.</html>";
            preparationDateTextField.setToolTipText(s);
            preparationDateTextField.addItemListener(new ItemListener() {
                public void itemStateChanged(ItemEvent e) {
                    setPreparationDate((String) preparationDateTextField.getSelectedItem());
                }
            });
        }
        return preparationDateTextField;
    }

    private JTextField getDeliveryFormTextField() {
        if (deliveryFormTextField == null) {
            deliveryFormTextField = new JTextField();
            deliveryFormTextField.setPreferredSize(new Dimension(98, 22));
            deliveryFormTextField.setHorizontalAlignment(0);
            String s = "<html>Num\351ro du DESADV<br>ou de l'exp\351dition.<br>Double click pour<br>g\351n\351rer un num\351ro<br>d'exp\351dition interne.</html>";
            deliveryFormTextField.setToolTipText(s);
            deliveryFormTextField.addKeyListener(new KeyAdapter() {
                public void keyReleased(KeyEvent e) {
                    setDeliveryForm(deliveryFormTextField.getText());
                }
            });
        }
        return deliveryFormTextField;
    }

    private JTextField getTruckingCompanyTextField() {
        if (truckingCompanyTextField == null) {
            truckingCompanyTextField = new JTextField();
            truckingCompanyTextField.setPreferredSize(new Dimension(98, 22));
            truckingCompanyTextField.setHorizontalAlignment(0);
            String s = "<html>Nom de la compagnie<br>de transports.</html>";
            truckingCompanyTextField.setToolTipText(s);
            truckingCompanyTextField.addKeyListener(new KeyAdapter() {
                public void keyReleased(KeyEvent e) {
                    setTruckingCompany(truckingCompanyTextField.getText());
                }
            });
        }
        return truckingCompanyTextField;
    }

    private JTextField getCustomerGLNTextField() {
        if (customerGLNTextField == null) {
            customerGLNTextField = new JTextField();
            customerGLNTextField.setPreferredSize(new Dimension(98, 22));
            customerGLNTextField.setHorizontalAlignment(0);
            String s = "<html>Num\351ro GLN<br>du client.</html>";
            customerGLNTextField.setToolTipText(s);
            customerGLNTextField.addKeyListener(new KeyAdapter() {
                public void keyReleased(KeyEvent e) {
                    setCustomerGLN(customerGLNTextField.getText());
                }
            });
        }
        return customerGLNTextField;
    }

    private JTextField getCustomerIDTextField() {
        if (customerIDTextField == null) {
            customerIDTextField = new JTextField();
            customerIDTextField.setPreferredSize(new Dimension(98, 22));
            customerIDTextField.setHorizontalAlignment(0);
            String s = "<html>Code du client<br>(JGestCom).</html>";
            customerIDTextField.setToolTipText(s);
            customerIDTextField.addKeyListener(new KeyAdapter() {
                public void keyReleased(KeyEvent e) {
                    setCustomerID(customerIDTextField.getText());
                }
            });
        }
        return customerIDTextField;
    }

    private JTextField getPalletGTINTextField() {
        if (palletGTINTextField == null) {
            palletGTINTextField = new JTextField();
            palletGTINTextField.setPreferredSize(new Dimension(98, 22));
            palletGTINTextField.setHorizontalAlignment(0);
            String s = "<html>Num\351ro GTIN<br>de la palette.</html>";
            palletGTINTextField.setToolTipText(s);
            palletGTINTextField.addKeyListener(new KeyAdapter() {
                public void keyReleased(KeyEvent e) {
                    setPalletGTIN(palletGTINTextField.getText());
                }
            });
        }
        return palletGTINTextField;
    }

    private JTextField getBoxGTINTextField() {
        if (boxGTINTextField == null) {
            boxGTINTextField = new JTextField();
            boxGTINTextField.setPreferredSize(new Dimension(98, 22));
            boxGTINTextField.setHorizontalAlignment(0);
            String s = "<html>Num\351ro GTIN<br>du carton.</html>";
            boxGTINTextField.setToolTipText(s);
            boxGTINTextField.addKeyListener(new KeyAdapter() {
                public void keyReleased(KeyEvent e) {
                    setBoxGTIN(boxGTINTextField.getText());
                }
            });
        }
        return boxGTINTextField;
    }

    private JTextField getOrderIdTextField() {
        if (orderIdTextField == null) {
            orderIdTextField = new JTextField();
            orderIdTextField.setPreferredSize(new Dimension(98, 22));
            orderIdTextField.setHorizontalAlignment(0);
            orderIdTextField.setForeground(new Color(0, 0, 153));
            orderIdTextField.setFont(new Font("Dialog", 1, 12));
            String s = "<html>Num\351ro du BL<br>(JGestCom).</html>";
            orderIdTextField.setToolTipText(s);
            orderIdTextField.addKeyListener(new KeyAdapter() {
                public void keyReleased(KeyEvent e) {
                    setOrderId(orderIdTextField.getText());
                }
            });
        }
        return orderIdTextField;
    }

    private JComboBox getStatusTextField() {
        if (statusTextField == null) {
            statusTextField = new JComboBox();
            statusTextField.setPreferredSize(new Dimension(98, 22));
            String s = "<html><b>V\351rifi\351 \351gale :</b><br>Contr\364le quantitatif et<br>contr\364le qualitatif<br>des produits exp\351di\351.</html>";
            statusTextField.setToolTipText(s);
            statusTextField.setModel(new DefaultComboBoxModel(new String[]{
                        "Non v\351rifi\351", "V\351rifi\351"
                    }));
            statusTextField.addItemListener(new ItemListener() {
                public void itemStateChanged(ItemEvent e) {
                    setStatus(statusTextField.getSelectedIndex());
                }
            });
        }
        return statusTextField;
    }

    private JTextField getSSCCTextField() {
        if (sSCCTextField == null) {
            sSCCTextField = new JTextField();
            sSCCTextField.setPreferredSize(new Dimension(98, 22));
            sSCCTextField.setHorizontalAlignment(0);
            String s = "<html>Num\351ro s\351quentiel<br>du colis.</html>";
            sSCCTextField.setToolTipText(s);
            sSCCTextField.addKeyListener(new KeyAdapter() {
                public void keyReleased(KeyEvent e) {
                    setSSCC(sSCCTextField.getText());
                }
            });
        }
        return sSCCTextField;
    }

    private JTextField getInsuranceCompanyTextField() {
        if (insuranceCompanyTextField == null) {
            insuranceCompanyTextField = new JTextField();
            insuranceCompanyTextField.setPreferredSize(new Dimension(98, 22));
            insuranceCompanyTextField.setHorizontalAlignment(0);
            String s = "<html>Nom de la compagnie<br>d'assurance</html>";
            insuranceCompanyTextField.setToolTipText(s);
            insuranceCompanyTextField.addKeyListener(new KeyAdapter() {
                public void keyReleased(KeyEvent e) {
                    setInsuranceCompany(insuranceCompanyTextField.getText());
                }
            });
        }
        return insuranceCompanyTextField;
    }

    private JTextField getParcelQuantityTextField() {
        if (parcelQuantityTextField == null) {
            parcelQuantityTextField = new JTextField();
            parcelQuantityTextField.setPreferredSize(new Dimension(98, 22));
            parcelQuantityTextField.setHorizontalAlignment(4);
            String s = "<html>Nombre de colis<br>ou de palettes</html>";
            parcelQuantityTextField.setToolTipText(s);
            parcelQuantityTextField.addKeyListener(new KeyAdapter() {
                public void keyReleased(KeyEvent e) {
                    setParcelQuantity(parcelQuantityTextField.getText());
                }
            });
        }
        return parcelQuantityTextField;
    }

    private DateComboBox getSendingDateTextField() {
        if (sendingDateTextField == null) {
            sendingDateTextField = new DateComboBox();
            sendingDateTextField.setPreferredSize(new Dimension(98, 22));
            sendingDateTextField.setToolTipText("Date d'exp\351dition");
            sendingDateTextField.addItemListener(new ItemListener() {
                public void itemStateChanged(ItemEvent e) {
                    setSendingDate((String) sendingDateTextField.getSelectedItem());
                }
            });
        }
        return sendingDateTextField;
    }

    private DateComboBox getDeliveryAnticipatedDateTextField() {
        if (deliveryAnticipatedDateTextField == null) {
            deliveryAnticipatedDateTextField = new DateComboBox();
            deliveryAnticipatedDateTextField.setPreferredSize(new Dimension(98, 22));
            String s = "<html>Livraison<br>pr\351vue le :</html>";
            deliveryAnticipatedDateTextField.setToolTipText(s);
            deliveryAnticipatedDateTextField.addItemListener(new ItemListener() {
                public void itemStateChanged(ItemEvent e) {
                    setDeliveryAnticipatedDate((String) deliveryAnticipatedDateTextField.getSelectedItem());
                }
            });
        }
        return deliveryAnticipatedDateTextField;
    }

    private JComboBox getPackagingTextField() {
        if (packagingTextField == null) {
            packagingTextField = new JComboBox();
            packagingTextField.setPreferredSize(new Dimension(98, 22));
            packagingTextField.setToolTipText("Conditionnement");
            packagingTextField.setModel(new DefaultComboBoxModel(MEUtility.PACKAGING));
            packagingTextField.addItemListener(new ItemListener() {
                public void itemStateChanged(ItemEvent e) {
                    setPackaging((String) packagingTextField.getSelectedItem());
                }
            });
        }
        return packagingTextField;
    }

    private JComboBox getUnitTextField() {
        if (unitTextField == null) {
            unitTextField = new JComboBox();
            unitTextField.setPreferredSize(new Dimension(98, 22));
            unitTextField.setToolTipText("Unit\351 de conditionnement");
            unitTextField.setModel(new DefaultComboBoxModel(MEUtility.SALES_UNIT));
            unitTextField.addItemListener(new ItemListener() {
                public void itemStateChanged(ItemEvent e) {
                    setUnit((String) unitTextField.getSelectedItem());
                }
            });
        }
        return unitTextField;
    }

    private JTextField getNotesTextField() {
        if (notesTextField == null) {
            notesTextField = new JTextField();
            notesTextField.setPreferredSize(new Dimension(260, 22));
            String s = "<html>Informations<br>sur le produit exp\351di\351 et<br>ces conditions d'emballage</html>";
            notesTextField.setToolTipText(s);
            notesTextField.addKeyListener(new KeyAdapter() {
                public void keyReleased(KeyEvent e) {
                    setNotes(notesTextField.getText());
                }
            });
        }
        return notesTextField;
    }

    private JTextField getWeightTextField() {
        if (weightTextField == null) {
            weightTextField = new JTextField();
            weightTextField.setPreferredSize(new Dimension(98, 22));
            weightTextField.setHorizontalAlignment(4);
            weightTextField.setForeground(new Color(0, 0, 153));
            String s = "<html>Poids du ou<br>des colis en kilo.<br><font color=red><b>Champs obligatoire !</b></font></html>";
            weightTextField.setToolTipText(s);
            weightTextField.addKeyListener(new KeyAdapter() {
                public void keyReleased(KeyEvent e) {
                    setWeight(weightTextField.getText());
                }
            });
        }
        return weightTextField;
    }

    private JTextField getDeliveryDateTextField() {
        if (deliveryDateTextField == null) {
            deliveryDateTextField = new JTextField();
            deliveryDateTextField.setPreferredSize(new Dimension(98, 22));
            deliveryDateTextField.setEditable(false);
            String s = "<html>Date r\351el de<br>la livraison.</html>";
            deliveryDateTextField.setToolTipText(s);
            deliveryDateTextField.addKeyListener(new KeyAdapter() {
                public void keyReleased(KeyEvent e) {
                    setDeliveryDate(deliveryDateTextField.getText());
                }
            });
        }
        return deliveryDateTextField;
    }

    private JTextField getInsuranceValueTextField() {
        if (insuranceValueTextField == null) {
            insuranceValueTextField = new JTextField();
            insuranceValueTextField.setPreferredSize(new Dimension(98, 22));
            insuranceValueTextField.setEditable(true);
            insuranceValueTextField.setToolTipText("Valeur assur\351e");
            insuranceValueTextField.setHorizontalAlignment(4);
            insuranceValueTextField.addKeyListener(new KeyAdapter() {
                public void keyReleased(KeyEvent e) {
                    setInsuranceValue(insuranceValueTextField.getText());
                }
            });
        }
        return insuranceValueTextField;
    }

    public int getAgencyId() {
        return agencyId + 1;
    }

    public void setAgencyId(int agencyId) {
        if (agencyId - 1 != this.agencyId) {
            int old = this.agencyId;
            this.agencyId = agencyId - 1;
            firePropertyChange("agencyId", old, agencyId - 1);
            getAgencyIdTextField().setSelectedIndex(agencyId - 1);
        }
    }

    public String getParcelQuantity() {
        return parcelQuantity;
    }

    public void setParcelQuantity(String parcelQuantity) {
        String old = this.parcelQuantity;
        this.parcelQuantity = parcelQuantity;
        firePropertyChange("parcelQuantity", old, parcelQuantity);
        getParcelQuantityTextField().setText(parcelQuantity);
    }

    public String getBoxGTIN() {
        return boxGTIN;
    }

    public void setBoxGTIN(String boxGTIN) {
        String old = this.boxGTIN;
        this.boxGTIN = boxGTIN;
        firePropertyChange("boxGTIN", old, boxGTIN);
        getBoxGTINTextField().setText(boxGTIN);
    }

    public String getOrderId() {
        return orderId;
    }

    public void setOrderId(String orderId) {
        String old = this.orderId;
        this.orderId = orderId;
        firePropertyChange("orderId", old, orderId);
        getOrderIdTextField().setText(orderId);
    }

    public String getDeliveryForm() {
        return deliveryForm;
    }

    public void setDeliveryForm(String deliveryForm) {
        String old = this.deliveryForm;
        this.deliveryForm = deliveryForm;
        firePropertyChange("deliveryForm", old, deliveryForm);
        getDeliveryFormTextField().setText(deliveryForm);
    }

    public String getSendingDate() {
        return sendingDate;
    }

    public void setSendingDate(String sendingDate) {
        String old = this.sendingDate;
        this.sendingDate = sendingDate;
        firePropertyChange("sendingDate", old, sendingDate);
        getSendingDateTextField().setModel(new DefaultComboBoxModel(new String[]{
                    sendingDate
                }));
    }

    public String getDeliveryAnticipatedDate() {
        return deliveryAnticipatedDate;
    }

    public void setDeliveryAnticipatedDate(String deliveryAnticipatedDate) {
        String old = this.deliveryAnticipatedDate;
        this.deliveryAnticipatedDate = deliveryAnticipatedDate;
        firePropertyChange("deliveryAnticipatedDate", old, deliveryAnticipatedDate);
        getDeliveryAnticipatedDateTextField().setModel(new DefaultComboBoxModel(new String[]{
                    deliveryAnticipatedDate
                }));
    }

    public String getPreparationDate() {
        return preparationDate;
    }

    public void setPreparationDate(String preparationDate) {
        String old = this.preparationDate;
        this.preparationDate = preparationDate;
        firePropertyChange("preparationDate", old, preparationDate);
        getPreparationDateTextField().setModel(new DefaultComboBoxModel(new String[]{
                    preparationDate
                }));
    }

    public String getWeight() {
        return weight;
    }

    public void setWeight(String weight) {
        String old = this.weight;
        this.weight = weight;
        firePropertyChange("weight", old, weight);
        getWeightTextField().setText(weight);
    }

    public String getDeliveryDate() {
        return deliveryDate;
    }

    public void setDeliveryDate(String deliveryDate) {
        String old = this.deliveryDate;
        this.deliveryDate = deliveryDate;
        firePropertyChange("deliveryDate", old, deliveryDate);
        getDeliveryDateTextField().setText(deliveryDate);
    }

    public String getInsuranceCompany() {
        return insuranceCompany;
    }

    public void setInsuranceCompany(String insuranceCompany) {
        String old = this.insuranceCompany;
        this.insuranceCompany = insuranceCompany;
        firePropertyChange("insuranceCompany", old, insuranceCompany);
        getInsuranceCompanyTextField().setText(insuranceCompany);
    }

    public String getNotes() {
        return notes;
    }

    public void setNotes(String notes) {
        String old = this.notes;
        this.notes = notes;
        firePropertyChange("notes", old, notes);
        getNotesTextField().setText(notes);
    }

    public String getPackaging() {
        return packaging;
    }

    public void setPackaging(String packaging) {
        if (!packaging.equals(this.packaging)) {
            String old = this.packaging;
            this.packaging = packaging;
            firePropertyChange("packaging", old, packaging);
            getPackagingTextField().setSelectedItem(packaging);
        }
    }

    public String getPalletGTIN() {
        return palletGTIN;
    }

    public void setPalletGTIN(String palletGTIN) {
        String old = this.palletGTIN;
        this.palletGTIN = palletGTIN;
        firePropertyChange("palletGTIN", old, palletGTIN);
        getPalletGTINTextField().setText(palletGTIN);
    }

    public String getSSCC() {
        return sSCC;
    }

    public void setSSCC(String sSCC) {
        String old = this.sSCC;
        this.sSCC = sSCC;
        firePropertyChange("sSCC", old, sSCC);
        getSSCCTextField().setText(sSCC);
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        if (status != this.status) {
            int old = this.status;
            this.status = status;
            firePropertyChange("status", old, status);
            getStatusTextField().setSelectedIndex(status);
        }
    }

    public String getInsuranceValue() {
        return insuranceValue;
    }

    public void setInsuranceValue(String insuranceValue) {
        String old = this.insuranceValue;
        this.insuranceValue = insuranceValue;
        firePropertyChange("insuranceValue", old, insuranceValue);
        getInsuranceValueTextField().setText(insuranceValue);
    }

    public JTextField getWeightJTextField() {
        return getWeightTextField();
    }

    public String getCustomerGLN() {
        return customerGLN;
    }

    public void setCustomerGLN(String customerGLN) {
        String old = this.customerGLN;
        this.customerGLN = customerGLN;
        firePropertyChange("customerGLN", old, customerGLN);
        getCustomerGLNTextField().setText(customerGLN);
    }

    public String getCustomerID() {
        return customerID;
    }

    public void setCustomerID(String customerID) {
        String old = this.customerID;
        this.customerID = customerID;
        firePropertyChange("customerID", old, customerID);
        getCustomerIDTextField().setText(customerID);
    }

    public String getTruckingCompany() {
        return truckingCompany;
    }

    public void setTruckingCompany(String truckingCompany) {
        String old = this.truckingCompany;
        this.truckingCompany = truckingCompany;
        firePropertyChange("truckingCompany", old, truckingCompany);
        getTruckingCompanyTextField().setText(truckingCompany);
    }

    public String getUnit() {
        return unit;
    }

    public void setUnit(String unit) {
        if (!unit.equals(this.unit)) {
            String old = this.unit;
            this.unit = unit;
            firePropertyChange("unit", old, unit);
            getUnitTextField().setSelectedItem(unit);
        }
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        String old = this.id;
        this.id = id;
        firePropertyChange("id", old, id);
        idLabel.setText(id);
    }

    public String getLastUpdateTime() {
        return lastUpdateTime;
    }

    public void setLastUpdateTime(String lastUpdateTime) {
        String old = this.lastUpdateTime;
        this.lastUpdateTime = lastUpdateTime;
        firePropertyChange("lastUpdateTime", old, lastUpdateTime);
        lastUpdateTimeLabel.setText(lastUpdateTime);
    }

    public String getLastUpdateUser() {
        return lastUpdateUser;
    }

    public void setLastUpdateUser(String lastUpdateUser) {
        String old = this.lastUpdateUser;
        this.lastUpdateUser = lastUpdateUser;
        firePropertyChange("lastUpdateUser", old, lastUpdateUser);
        lastUpdateUserLabel.setText(lastUpdateUser);
    }

    public JTextField getDeliveryFormJTextField() {
        return getDeliveryFormTextField();
    }

    public JTextField getOrderIdJTextField() {
        return getOrderIdTextField();
    }

    public void cleanField(boolean all) {
        if (all) {
            setAgencyId(1);
            preparationDate = (new MEDate()).getPlain();
            preparationDateTextField.setModel(new DefaultComboBoxModel(new String[]{
                        preparationDate
                    }));
            truckingCompanyTextField.setText("");
            insuranceCompanyTextField.setText("");
            sendingDateTextField.setModel(new DefaultComboBoxModel(new String[]{
                        ""
                    }));
            deliveryAnticipatedDateTextField.setModel(new DefaultComboBoxModel(new String[]{
                        ""
                    }));
            deliveryFormTextField.setText("");
            customerGLNTextField.setText("");
            customerIDTextField.setText("");
            palletGTINTextField.setText("");
            sSCCTextField.setText("");
            weightTextField.setText("");
            parcelQuantityTextField.setText("1");
            truckingCompany = null;
            insuranceCompany = null;
            sendingDate = null;
            deliveryAnticipatedDate = null;
            deliveryForm = null;
            customerGLN = null;
            customerID = null;
            palletGTIN = null;
            sSCC = null;
            weight = null;
            parcelQuantity = "1";
        }
        boxGTINTextField.setText("");
        orderIdTextField.setText("");
        setStatus(0);
        setPackaging("1");
        setUnit("pi\350ce");
        notesTextField.setText("");
        deliveryDateTextField.setText("");
        insuranceValueTextField.setText("");
        lastUpdateUserLabel.setText("");
        lastUpdateTimeLabel.setText("");
        idLabel.setText("");
        boxGTIN = null;
        orderId = null;
        notes = null;
        deliveryDate = null;
        insuranceValue = null;
        lastUpdateUser = null;
        lastUpdateTime = null;
        id = null;
    }
    private JPanel jPanel;
    private JLabel lastUpdateUserLabel;
    private JLabel lastUpdateTimeLabel;
    private JLabel idLabel;
    private JLabel agencyIdLabel;
    private JComboBox agencyIdTextField;
    private JLabel preparationDateLabel;
    private DateComboBox preparationDateTextField;
    private JLabel deliveryFormLabel;
    private JTextField deliveryFormTextField;
    private JLabel truckingCompanyLabel;
    private JTextField truckingCompanyTextField;
    private JLabel customerGLNLabel;
    private JTextField customerGLNTextField;
    private JLabel customerIDLabel;
    private JTextField customerIDTextField;
    private JLabel palletGTINLabel;
    private JTextField palletGTINTextField;
    private JLabel boxGTINLabel;
    private JTextField boxGTINTextField;
    private JLabel orderIdLabel;
    private JTextField orderIdTextField;
    private JLabel statusLabel;
    private JComboBox statusTextField;
    private JLabel sSCCLabel;
    private JTextField sSCCTextField;
    private JLabel insuranceCompanyLabel;
    private JTextField insuranceCompanyTextField;
    private JLabel parcelQuantityLabel;
    private JTextField parcelQuantityTextField;
    private JLabel sendingDateLabel;
    private DateComboBox sendingDateTextField;
    private JLabel deliveryAnticipatedDateLabel;
    private DateComboBox deliveryAnticipatedDateTextField;
    private JLabel packagingLabel;
    private JComboBox packagingTextField;
    private JLabel unitLabel;
    private JComboBox unitTextField;
    private JLabel notesLabel;
    private JTextField notesTextField;
    private JLabel weightLabel;
    private JTextField weightTextField;
    private JLabel deliveryDateLabel;
    private JTextField deliveryDateTextField;
    private JLabel insuranceValueLabel;
    private JTextField insuranceValueTextField;
    private int agencyId;
    private String preparationDate;
    private String deliveryForm;
    private String truckingCompany;
    private String customerGLN;
    private String customerID;
    private String palletGTIN;
    private String boxGTIN;
    private String orderId;
    private int status;
    private String sSCC;
    private String insuranceCompany;
    private String parcelQuantity;
    private String sendingDate;
    private String deliveryAnticipatedDate;
    private String packaging;
    private String unit;
    private String notes;
    private String weight;
    private String deliveryDate;
    private String insuranceValue;
    private String lastUpdateUser;
    private String lastUpdateTime;
    private String id;
    private JPanel jPanel1;
    private JPanel jPanel2;
    private JPanel jPanel3;
    private JPanel jPanel4;
    private JPanel jPanel5;
}
